#!/bin/bash 
cd $(dirname $0) 
path=$(pwd) 
echo now in $path 
cd ../../bundleRepository/runtime 
LDruntimePath=$(pwd) 
echo LDruntimePath is $LDruntimePath 
cd ../commonlib 
LDcommonlibPath=$(pwd) 
cd ../bundles 
bundlesPath=$(pwd) 

subcomlibs=`find . -name commonlib` 
for libPath in $subcomlibs 
do 
    temp=$bundlesPath$libPath 
    nowPath=`echo ${temp/./}` 
    export LD_LIBRARY_PATH=${nowPath}:${LD_LIBRARY_PATH} 
done; 

env | grep LD_LIBRARY_PATH 

strBundlePath="<bundlePath>" 
strContainer="<containerBundle>" 
cd ../../app/config 
bundlePath=$(pwd) 
bundleName=$(pwd) 
while read LINE 
do 
if [[ $LINE =~ $strBundlePath ]] 
then 
    tempA=${LINE#*>} 
    tempB=${tempA%<*} 
    bundlePath=$tempB 
fi 
if [[ $LINE =~ $strContainer ]] 
then 
    read oneLine 
    tempA=${oneLine#*>} 
    tempB=${tempA%<*} 
    read anotherLine 
    tempAA=${anotherLine#*>} 
    tempBB=${tempAA%<*} 
    bundleName=${tempB}_${tempBB} 
    break 
fi 
done < ./app.config 
cd .. 
appPath=$(pwd) 
echo bundlesPath is $bundlesPath 
echo appPath is $appPath 

app=${bundlePath}/${bundleName}/bin/Linux/IA32/TestKTContainer
export LD_LIBRARY_PATH=${LDruntimePath}:${LDcommonlibPath}:${LD_LIBRARY_PATH}
$app $bundlesPath $appPath/
